const Mock = require('mockjs')

// 使用 mockjs 模拟数据
Mock.mock('/data/register', 'post', req => {
    if (JSON.parse(req.body).tel && JSON.parse(req.body).password) {
        return {
            data: {
                code: 0,
                status: "register success "
            }
        }
    }
    return {
        data: {
            code: 1,
            status: "register fail "
        }
    }
})
Mock.mock('/data/login', 'post', req => {
    let options = {};
    if (JSON.parse(req.body).tel && JSON.parse(req.body).password == '000000' && JSON.parse(req.body).yzm) {
        options = {
            data: {
                code: 0,
                status: "login success "
            }
        }
    } else {
        options = {
            data: {
                code: 1,
                status: "login success "
            }
        }
    }
    if (JSON.parse(req.body).tel && JSON.parse(req.body).sms) {
        options = {
            data: {
                code: 2,
                status: "login success "
            }
        }
    } else {
        options = {
            data: {
                code: 3,
                status: "login fail "
            }
        }
    }

    return options;
})